<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />



  <meta name="google-site-verification" content="TrUnMASAEpWPLf28sUVl5VSxwgl4myBCO_6PiHidBaU" />













  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.lug.ustc.edu.cn//css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






  

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Java,JIRA," />





  <link rel="alternate" href="/atom.xml" title="Sam's Blog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="1. JIRA REST API 可以做什么？The Atlassian REST APIs provide a standard interface for interacting with JIRA and our other applications.  REST APIs provide access to resources (data entities) via URI paths.">
<meta name="keywords" content="Java,JIRA">
<meta property="og:type" content="article">
<meta property="og:title" content="Jira rest api 使用经验">
<meta property="og:url" content="http://blog.lisanlai.cn/2017/03/26/Jira-rest-api-使用经验/index.html">
<meta property="og:site_name" content="Sam&#39;s Blog">
<meta property="og:description" content="1. JIRA REST API 可以做什么？The Atlassian REST APIs provide a standard interface for interacting with JIRA and our other applications.  REST APIs provide access to resources (data entities) via URI paths.">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://blog.lisanlai.cn/2017/03/26/Jira-rest-api-使用经验/jira-oauth-dance.png">
<meta property="og:updated_time" content="2018-07-10T02:38:15.609Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Jira rest api 使用经验">
<meta name="twitter:description" content="1. JIRA REST API 可以做什么？The Atlassian REST APIs provide a standard interface for interacting with JIRA and our other applications.  REST APIs provide access to resources (data entities) via URI paths.">
<meta name="twitter:image" content="http://blog.lisanlai.cn/2017/03/26/Jira-rest-api-使用经验/jira-oauth-dance.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '6275635457204159000',
      author: 'Author'
    },
    algolia: {
      applicationID: 'KWML0K50GI',
      apiKey: 'd54291e92bb62d32f0fbc5f0b6732a22',
      indexName: 'Index_blog_lisanlai_cn',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://blog.lisanlai.cn/2017/03/26/Jira-rest-api-使用经验/"/>





  <title> Jira rest api 使用经验 | Sam's Blog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  














  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Sam's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description"></h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  
  <div class="algolia-popup popup search-popup">
    <div class="algolia-search">
      <div class="algolia-search-input-icon">
        <i class="fa fa-search"></i>
      </div>
      <div class="algolia-search-input" id="algolia-search-input"></div>
    </div>

    <div class="algolia-results">
      <div id="algolia-stats"></div>
      <div id="algolia-hits"></div>
      <div id="algolia-pagination" class="algolia-pagination"></div>
    </div>

    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
  </div>




    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.lisanlai.cn/2017/03/26/Jira-rest-api-使用经验/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李三来">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sam's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                Jira rest api 使用经验
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-26T22:46:49+08:00">
                2017-03-26
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Development/" itemprop="url" rel="index">
                    <span itemprop="name">Development</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/03/26/Jira-rest-api-使用经验/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/03/26/Jira-rest-api-使用经验/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="1-JIRA-REST-API-可以做什么？"><a href="#1-JIRA-REST-API-可以做什么？" class="headerlink" title="1. JIRA REST API 可以做什么？"></a>1. JIRA REST API 可以做什么？</h2><div class="note "><p>The Atlassian REST APIs provide a standard interface for interacting with JIRA and our other applications. </p>
<p>REST APIs provide access to resources (data entities) via URI paths. To use a REST API, your application will make an HTTP request and parse the response. Your methods will be the standard HTTP methods like GET, PUT, POST and DELETE. REST APIs operate over HTTP(s) making it easy to use with any programming language or framework. The input and output format for the JIRA REST APIs is <a href="http://www.json.org/" target="_blank" rel="noopener">JSON</a>.</p>
</div>
<p>我们可以通过REST API去访问收保护的资源，例如增、删、改、查ISSUES 。。。。。</p>
<p>支持标准的HTTP method，例如 GET, PUT, POST , DELETE</p>
<p>所有的API的input 和 output 都是 JSON 格式。</p>
<div class="note primary"><p>Rest API Reference ： <a href="https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis" target="_blank" rel="noopener">https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis</a></p>
</div>
<div class="note info"><p>REST URI 结构 ： <a href="http://host:port/context/rest/api-name/api-version/resource-name" target="_blank" rel="noopener">http://host:port/context/rest/api-name/api-version/resource-name</a></p>
</div>
<div class="note success"><p>资源列表 ： <a href="https://developer.atlassian.com/static/rest/jira/6.1.html" target="_blank" rel="noopener">https://developer.atlassian.com/static/rest/jira/6.1.html</a></p>
</div>
<a id="more"></a>
<h2 id="2-JIRA-REST-API鉴权方式"><a href="#2-JIRA-REST-API鉴权方式" class="headerlink" title="2. JIRA REST API鉴权方式"></a>2. JIRA REST API鉴权方式</h2><blockquote class="blockquote-center"><p>The REST APIs support basic authentication, cookie-based (session) authentication, and OAuth. See the examples of <a href="https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-basic-authentication" target="_blank" rel="noopener">basic authentication</a>, <a href="https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-cookie-based-authentication" target="_blank" rel="noopener">cookie-based authentication</a>, and <a href="https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-oauth-authentication" target="_blank" rel="noopener">OAuth</a>.</p>
</blockquote>
<p>JIRA REST API 支持3种鉴权方式：</p>
<ol>
<li><a href="https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-basic-authentication" target="_blank" rel="noopener">basic authentication</a></li>
<li><a href="https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-cookie-based-authentication" target="_blank" rel="noopener">cookie-based authentication</a></li>
<li><a href="https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-oauth-authentication" target="_blank" rel="noopener">OAuth</a></li>
</ol>
<div class="note warning"><p>目前JIRA REST API 只支持OAuth1.0</p>
</div>
<h2 id="3-如何使用OAuth方式鉴权"><a href="#3-如何使用OAuth方式鉴权" class="headerlink" title="3. 如何使用OAuth方式鉴权"></a>3. 如何使用OAuth方式鉴权</h2><p>因为basic authentication 和 cookie-based authentication两种方式比较简单，且不推荐使用，这里我说说推荐使用的OAuth方式如何玩。</p>
<ol>
<li>首先需要到Jira上配置Application link，注册一个新的consumer</li>
<li>配置客户端oauth信息</li>
</ol>
<h3 id="Step1-Create-application-link"><a href="#Step1-Create-application-link" class="headerlink" title="Step1: Create application link"></a>Step1: Create application link</h3><div class="note "><p>JIRA Administration &gt; System &gt; Applications tab &gt; Application links</p>
</div>
<h3 id="Step2-Configuring-the-client"><a href="#Step2-Configuring-the-client" class="headerlink" title="Step2: Configuring the client"></a>Step2: Configuring the client</h3><table>
<thead>
<tr>
<th style="text-align:left">OAuth Config</th>
<th style="text-align:left">value</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">request token url</td>
<td style="text-align:left">JIRA_BASE_URL + “/plugins/servlet/oauth/request-token”</td>
</tr>
<tr>
<td style="text-align:left">authorization url</td>
<td style="text-align:left">JIRA_BASE_URL + “/plugins/servlet/oauth/authorize””</td>
</tr>
<tr>
<td style="text-align:left">access token url</td>
<td style="text-align:left">JIRA_BASE_URL + “/plugins/servlet/oauth/access-token”</td>
</tr>
<tr>
<td style="text-align:left">oauth signing type</td>
<td style="text-align:left">RSA-SHA1，需要生成key pair，且粘贴public key到oauth配置里面</td>
</tr>
<tr>
<td style="text-align:left">consumer key</td>
<td style="text-align:left">Step1里面配置的值</td>
</tr>
</tbody>
</table>
<h2 id="4-使用Java-client来获取access-token"><a href="#4-使用Java-client来获取access-token" class="headerlink" title="4. 使用Java client来获取access token"></a>4. 使用Java client来获取access token</h2><div class="note success"><p>Java oauth client 是基于John Kristian的源码做了一些改进</p>
<p>Github ：<a href="https://github.com/lisanlai/jira.oauth.client" target="_blank" rel="noopener">https://github.com/lisanlai/jira.oauth.client</a></p>
</div>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Created by lisanlai on 2017/3/27.</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ClientTest</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String BASEURL = <span class="string">"Jira domain url"</span>;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String CONSUMER_KEY = <span class="string">"你自己配置的consumer key"</span>;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String CONSUMER_PRIVATE_KEY = <span class="string">"你自己生成的RSA private key"</span>;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String CALLBACK_URI = <span class="string">"http://requestb.in/12f4ung1"</span>;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> <span class="keyword">throws</span> Exception </span>&#123;</span><br><span class="line">        AtlassianOAuthClient jiraoAuthClient = <span class="keyword">new</span> AtlassianOAuthClient(CONSUMER_KEY, CONSUMER_PRIVATE_KEY, BASEURL, CALLBACK_URI);</span><br><span class="line">        <span class="comment">//STEP 1: 获取request token</span></span><br><span class="line">        TokenSecretVerifierHolder requestToken = jiraoAuthClient.getRequestToken();</span><br><span class="line">        String authorizeUrl = jiraoAuthClient.getAuthorizeUrlForToken(requestToken.token);</span><br><span class="line">        System.out.println(<span class="string">"Token is "</span> + requestToken.token);</span><br><span class="line">        System.out.println(<span class="string">"Token secret is "</span> + requestToken.secret);</span><br><span class="line">        System.out.println(<span class="string">"Retrieved request token. go to "</span> + authorizeUrl);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//STEP2 : 授权， 打开STEP1里面获取到的authorize url</span></span><br><span class="line">        <span class="comment">//登录jira并点击allow按钮</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">//STEP3 : 获取 access token</span></span><br><span class="line">        <span class="comment">//getAccessToken("810qrpbOePqXdMRWcoOuMLdoBoLuh9To", "M4O6qaRC4OVDKzQOCcVrmvvpCNkYmhpm", "0aOMdW");</span></span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">getAccessToken</span><span class="params">(String requestToken, String tokenSecret, String verifier)</span> <span class="keyword">throws</span> OAuthException, IOException, URISyntaxException </span>&#123;</span><br><span class="line">        AtlassianOAuthClient jiraoAuthClient = <span class="keyword">new</span> AtlassianOAuthClient(CONSUMER_KEY, CONSUMER_PRIVATE_KEY, BASEURL, CALLBACK_URI);</span><br><span class="line">        String accessToken = jiraoAuthClient.swapRequestTokenForAccessToken(requestToken, tokenSecret, verifier);</span><br><span class="line">        System.out.println(<span class="string">"Access token is : "</span> + accessToken);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="5-使用REST-API创建-修改-查询issue"><a href="#5-使用REST-API创建-修改-查询issue" class="headerlink" title="5. 使用REST API创建/修改/查询issue"></a>5. 使用REST API创建/修改/查询issue</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">String accessToken = <span class="string">"access token"</span>;</span><br><span class="line">String requestUrl =  JIRA_BASE_URL + <span class="string">"/rest/api/2/issue"</span>;</span><br><span class="line">String jsonBody = <span class="string">"&#123;\n"</span> +</span><br><span class="line">                <span class="string">"    \"fields\": &#123;\n"</span> +</span><br><span class="line">                <span class="string">"       \"project\":\n"</span> +</span><br><span class="line">                <span class="string">"       &#123; \n"</span> +</span><br><span class="line">                <span class="string">"          \"key\": \"ASYNC\"\n"</span> +</span><br><span class="line">                <span class="string">"       &#125;,\n"</span> +</span><br><span class="line">                <span class="string">"       \"summary\": \"REST ye merry gentlemen.\",\n"</span> +</span><br><span class="line">                <span class="string">"       \"description\": \"Creating of an issue using project keys and issue type names using the REST API\",\n"</span> +</span><br><span class="line">                <span class="string">"       \"issuetype\": &#123;\n"</span> +</span><br><span class="line">                <span class="string">"          \"name\": \"Bug\"\n"</span> +</span><br><span class="line">                <span class="string">"       &#125;\n"</span> +</span><br><span class="line">                <span class="string">"   &#125;\n"</span> +</span><br><span class="line">                <span class="string">"&#125;"</span>;</span><br><span class="line"></span><br><span class="line">String responseAsString = jiraoAuthClient.makeAuthenticatedRequest(accessToken, OAuthMessage.POST, requestUrl, Collections.emptySet(), jsonBody);</span><br><span class="line">System.out.println(<span class="string">"RESPONSE IS"</span> + responseAsString);</span><br></pre></td></tr></table></figure>
<h2 id="6-JIRA-OAuth-dance"><a href="#6-JIRA-OAuth-dance" class="headerlink" title="6. JIRA OAuth dance"></a>6. JIRA OAuth dance</h2><img src="/2017/03/26/Jira-rest-api-使用经验/jira-oauth-dance.png" title="JIRA OAuth dance">
      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Java/" rel="tag"># Java</a>
          
            <a href="/tags/JIRA/" rel="tag"># JIRA</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/12/14/Spring-Boot-Mybatis-多数据源配置/" rel="next" title="Spring-Boot Mybatis 多数据源配置">
                <i class="fa fa-chevron-left"></i> Spring-Boot Mybatis 多数据源配置
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/03/27/Error-Cannot-find-module-hexo-util/" rel="prev" title="Error: Cannot find module 'hexo-util'">
                Error: Cannot find module 'hexo-util' <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          

  <p>热评文章</p>
  <div class="ds-top-threads" data-range="weekly" data-num-items="4"></div>


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2017/03/26/Jira-rest-api-使用经验/"
           data-title="Jira rest api 使用经验" data-url="http://blog.lisanlai.cn/2017/03/26/Jira-rest-api-使用经验/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.png"
               alt="李三来" />
          <p class="site-author-name" itemprop="name">李三来</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
           
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">14</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">4</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">20</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/lisanlai" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/SanlaiLi" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-block">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://zoom.us" title="zoom" target="_blank">zoom</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-JIRA-REST-API-可以做什么？"><span class="nav-number">1.</span> <span class="nav-text">1. JIRA REST API 可以做什么？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-JIRA-REST-API鉴权方式"><span class="nav-number">2.</span> <span class="nav-text">2. JIRA REST API鉴权方式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-如何使用OAuth方式鉴权"><span class="nav-number">3.</span> <span class="nav-text">3. 如何使用OAuth方式鉴权</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Step1-Create-application-link"><span class="nav-number">3.1.</span> <span class="nav-text">Step1: Create application link</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Step2-Configuring-the-client"><span class="nav-number">3.2.</span> <span class="nav-text">Step2: Configuring the client</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-使用Java-client来获取access-token"><span class="nav-number">4.</span> <span class="nav-text">4. 使用Java client来获取access token</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-使用REST-API创建-修改-查询issue"><span class="nav-number">5.</span> <span class="nav-text">5. 使用REST API创建/修改/查询issue</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-JIRA-OAuth-dance"><span class="nav-number">6.</span> <span class="nav-text">6. JIRA OAuth dance</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">李三来</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  






  
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.1.3/jquery.min.js"></script>

  
  <script type="text/javascript" src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>

  
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery_lazyload/1.9.7/jquery.lazyload.min.js"></script>

  
  <script type="text/javascript" src="https://cdn.bootcss.com/velocity/1.2.1/velocity.min.js"></script>

  
  <script type="text/javascript" src="https://cdn.bootcss.com/velocity/1.2.1/velocity.ui.min.js"></script>

  
  <script type="text/javascript" src="https://cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.pack.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"lisanlai"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
      
      <script src="https://cdn.bootcss.com/UAParser.js/0.7.9/ua-parser.min.js"></script>
      <script src="/js/src/hook-duoshuo.js?v=5.1.0"></script>
    
    
    <script src="https://cdn.bootcss.com/UAParser.js/0.7.9/ua-parser.min.js"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  
















  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>




  
  
  
  <link rel="stylesheet" href="/lib/algolia-instant-search/instantsearch.min.css">

  
  
  <script src="/lib/algolia-instant-search/instantsearch.min.js"></script>
  

  <script src="/js/src/algolia-search.js?v=5.1.0"></script>



  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

  

</body>
</html>
